
/**		
 * 
 *	uk.co.lmfm.guppy.controller.CreateProjectCommand
 *	
 *	@version 1.00 | Jan 22, 2010
 *	@author Justin Windle
 *  
 **/
 
package uk.co.lmfm.guppy.controller 
{
	import org.osflash.thunderbolt.Logger;

	import uk.co.lmfm.guppy.model.vo.SettingsVO;
	import uk.co.lmfm.guppy.model.SettingsProxy;
	import uk.co.lmfm.guppy.model.EclipseProxy;
	import uk.co.lmfm.guppy.model.vo.ProjectVO;

	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.patterns.command.SimpleCommand;

	/**
	 * CreateProjectCommand
	 */
	public class CreateProjectCommand extends SimpleCommand implements ICommand 
	{
		override public function execute(notification : INotification) : void
		{
			super.execute(notification);
			
			var sqlProxy : SettingsProxy = facade.retrieveProxy(SettingsProxy.NAME) as SettingsProxy;
			var eclipseProxy : EclipseProxy = facade.retrieveProxy(EclipseProxy.NAME) as EclipseProxy;
			
			var settings : SettingsVO = sqlProxy.readSettings();
			var project : ProjectVO = notification.getBody() as ProjectVO;
			project.author = settings.username;
			
			var info : String = "Create Project:";
			
			info += "\n\tFolder:\t" + project.folder.nativePath;
			info += "\n\tPlayer:\t" + project.playerVersion.name;
			info += "\n\tCorelib:\t" + project.playerVersion.corelib.name;
			info += "\n\tSDK ID:\t" + project.playerVersion.corelib.sdk.id;			info += "\n\tSDK Path:\t" + project.playerVersion.corelib.sdk.path;			info += "\n\tSDK ANT:\t" + project.playerVersion.corelib.sdk.ant;
			
			Logger.info(info);
			
			eclipseProxy.createProject(project, settings.libraryPath);
		}
	}
}
